home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / 80x0393.zip / DIALER.ASM < prev    next >
Assembly Source File  |  1992-09-30  |  6KB  |  253 lines

  1. ;
  2. ;  DIALER.ASM 
  3. ;  Resident dialer
  4. ;
  5. ;  Author: Inbar Raz
  6. ;  Placed in public domain
  7.  
  8.  
  9. Dialres segment
  10.  
  11.         assume  cs:Dialres, ds:Dialres
  12.  
  13.         org     100h
  14.  
  15. Start:  jmp     Begin
  16.  
  17. Old15   dw      ?,?
  18. Port    dw      0001h           ; 0000 - COM1, 0001 - COM2, etc.
  19. NumBuf  db      22 dup (0)
  20. NumPtr  dw      ?
  21. AllDone db      000h
  22. ExitFlag db     000h
  23. Running db      000h
  24. Wanted  db      000h
  25. DialPre db      'ATD'
  26. DialPre1 db     'T', 000h
  27. XlatTbl db      037h, 038h, 039h, 0, 034h, 035h
  28.         db      036h, 0, 031h, 032h, 033h, 030h
  29.  
  30. New15   proc    far
  31.  
  32.         push    ax
  33.         push    bx
  34.         push    cx
  35.         push    dx
  36.         push    si
  37.         push    di
  38.         push    bp
  39.         push    sp
  40.         push    ds
  41.         push    es
  42.  
  43.         cmp     ax,08500h
  44.         jnz     GoOn1
  45.  
  46.         cmp     cs:Running,000h         ; Not already running?
  47.         jnz     GoOn1
  48.  
  49.         cli
  50.  
  51.         mov     ax,cs
  52.         mov     ds,ax
  53.         mov     es,ax
  54.  
  55.         mov     Running,001h
  56.  
  57.         mov     bx,offset NumBuf
  58.         mov     NumPtr,bx
  59.         mov     cx,022d
  60. Loop3:  mov     byte ptr [bx],00
  61.         inc     ax
  62.         loop    Loop3                           ; Erase existing number
  63.  
  64.         mov     AllDone,000h
  65.  
  66.         jmp     Kbd
  67.  
  68. GoOn1:  mov     cs:ExitFlag,000h
  69.         jmp     GoOn
  70.  
  71. GoodBye1:
  72.         jmp     GoodBye
  73.  
  74. Kbd:    mov     ah,010h
  75.         int     16h                             ; Extended kbd read
  76.  
  77.         cmp     al,01Bh                         ; ESCape?
  78.         jz      GoodBye1
  79.  
  80.         cmp     al,00Dh                         ; Done?
  81.         jz      Done1
  82.  
  83.         cmp     ax,00E08h                       ; Backspace?
  84.         jnz     Label1
  85.  
  86.         mov     bx,offset NumBuf
  87.         cmp     NumPtr,bx
  88.         jbe     Kbd                             ; Beginning of line?
  89.  
  90.         dec     NumPtr
  91.         mov     si,NumPtr
  92.         mov     byte ptr [si],000h              ;  from buffer too
  93.  
  94.         jmp     Kbd
  95.  
  96. Done1:  jmp     Done
  97.  
  98. Label1: cmp     al,000h                         ; Extended ASCII?
  99.         jnz     Label2
  100.  
  101.         cmp     ah,047h                         ; Keypad?
  102.         jb      Kbd
  103.  
  104.         cmp     ah,052h                         ;  - " -
  105.         ja      Kbd
  106.  
  107.         mov     bx,offset XlatTbl
  108.         sub     bx,047h                         ; To make up for partiality
  109.         mov     al,ah
  110.         xlat                                    ; Translate key
  111.  
  112.         cmp     al,000h                         ; If illegal,
  113.         jz      Kbd                             ;  get a new one
  114.  
  115. Echo:   mov     bx,offset NumBuf
  116.         add     bx,020d
  117.         cmp     NumPtr,bx
  118.         jnz     Label3
  119.  
  120.         mov     ax,00E07h
  121.         int     10h                             ; Too many digits
  122.  
  123.         jmp     Kbd
  124.  
  125. Label3: mov     si,NumPtr
  126.         mov     byte ptr [si],al
  127.         inc     NumPtr                          ;  and remember it
  128.  
  129.         cmp     AllDone,001h
  130.         jz      Done
  131.  
  132. Kbd1:   jmp     Kbd
  133.  
  134. Label2: cmp     al,02Dh
  135.         jz      Echo                            ; '-'
  136.  
  137.         cmp     ah,026h
  138.         jnz     Label5
  139.  
  140.         and     al,04Fh
  141.         cmp     al,04Ch
  142.         jnz     Kbd1
  143.  
  144.         mov     bx,offset NumBuf
  145.         cmp     NumPtr,bx
  146.         jne     Kbd1                            ; Beginning of line?
  147.  
  148.         mov     AllDone,001h
  149.  
  150.         jmp     Echo
  151.  
  152. Label5: cmp     al,030h
  153.         jb      Kbd1
  154.  
  155.         cmp     al,039h
  156.         jna     Echo
  157.  
  158.         jmp     Kbd1
  159.  
  160. Done:   mov     si,NumPtr
  161.         mov     di,offset NumBuf
  162.         cmp     si,di
  163.         jz      GoodBye
  164.  
  165.         mov     byte ptr [si],00Dh
  166.  
  167.         cmp     AllDone,001h
  168.         jnz     Label6
  169.  
  170.         mov     DialPre1,000h                   ; If redial, delete 'T'
  171.  
  172. Label6: mov     si,offset DialPre
  173.         call    SndStr
  174.  
  175.         cmp     AllDone,001h
  176.         jnz     Label7
  177.  
  178.         mov     DialPre1,'T'                    ;  and then restore it
  179.  
  180. Label7: mov     si,offset NumBuf
  181.         call    SndStr
  182.  
  183.         mov     ah,010h
  184.         int     16h                             ; Wait for a key
  185.  
  186.         cmp     ax,0011Bh                       ; Is it ESC?
  187.         jz      GoodBye                         ; If yes, don't hang-up
  188.  
  189. Loop1:  mov     si,offset NumBuf
  190.         call    SndStr                          ; Make the modem hang-up
  191.  
  192. GoodBye:
  193.         mov     Running,000h
  194.         mov     Wanted,000h
  195.         mov     ExitFlag,001h
  196.  
  197. GoOn:   pop     es
  198.         pop     ds
  199.         pop     sp
  200.         pop     bp
  201.         pop     di
  202.         pop     si
  203.         pop     dx
  204.         pop     cx
  205.         pop     bx
  206.         pop     ax
  207.  
  208.         cmp     cs:ExitFlag,000h
  209.         jz      Label9
  210.         iret
  211.  
  212. Label9: jmp     cs:dword ptr [old15]
  213.  
  214. Sndstr  proc    near
  215.  
  216.         mov     al,[si]
  217.         or      al,al
  218.         jz      Leavs
  219.  
  220.         mov     dx,Port
  221.         mov     ah,01
  222.         int     14H                             ; Serial port output
  223.  
  224.         and     ah,080h
  225.         jnz     MdmErr
  226.  
  227.         inc     si
  228.         jmp     Sndstr
  229.  
  230. MdmErr: jmp     GoodBye
  231.  
  232. Leavs:  ret
  233.  
  234. Sndstr  endp
  235.  
  236. New15   endp
  237.  
  238. Begin:  mov     ax,03515h
  239.         int     21h
  240.  
  241.         mov     [old15],bx
  242.         mov     [old15+2],es
  243.  
  244.         mov     dx,offset New15
  245.         mov     ax,02515h
  246.         int     21h
  247.  
  248.         mov     dx,offset Begin
  249.         int     27h
  250.  
  251. Dialres ends
  252.         end     start
  253.